package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author ：Shine
 * @description：
 * @date ：2021/3/22 16:28
 */
@RestController
@RequestMapping("/supplier/")
public class SupplierController {
    @Autowired
    private SupplierService supplierService;

    //http://localhost:8080/supplier/list
    @PostMapping("list")
    @RequiresPermissions(value = "供应商管理")
    public Map<String, Object> list(Integer page, Integer rows, String supplierName) {
        return supplierService.list(page, rows, supplierName);
    }

    // 供应商添加或修改
//http://localhost:8080/supplier/save?supplierId=1
    @PostMapping("save")
    @RequiresPermissions(value = "供应商管理")
    public ServiceVO save(Supplier supplier) {
        return supplierService.saveSupplierById(supplier);
    }

//    http://localhost:8080/supplier/delete
    @PostMapping("delete")
    @RequiresPermissions(value = "供应商管理")
    public ServiceVO delete(String ids){
        return supplierService.delete(ids);
    }
}

